<script type="text/javascript">
    function sendRespond(questionid, val) {
        $.post(base_url+"/site/ajax_questionnaire_next",{
            question_id : questionid,
            question_answer : val,
            sum_answered : $('#sum_answered').val()
        },
        function(str){
            $("#sum_answered").val(1+(+$("#sum_answered").val()));
            if(str=="succ_end"){
                window.location.replace(base_url+"site/questionnaire_end");
            }else{
                $.post(base_url+"/site/ajax_get_question",{question_id: str},
                function(next_content){
                    //alert(next_content);
                    $("#questionContent").slideDown(200, callback(next_content));
                    //$('#questionContent').html(next_content);
                    $('#yesButton').attr("onclick","");
                    $('#noButton').attr("onclick","");
                    $('#yesButton').attr("onclick","sendRespond("+str+",1)");
                    $('#noButton').attr("onclick","sendRespond("+str+",0)");
                });
            }
        }
    );
    }
    var callback = function(next_content){
        $('#questionContent').slideUp(200, function(){$('#questionContent').html(next_content);});
    }
</script>

<input id="sum_answered" type="hidden" value=0>
<div class="post">
    <div class ="box_container">
        <h2 class="title">Kuesioner Pelayanan Plasa Telkom</h2><br/>
        <?php if ($is_empty != 1) { ?>
            <span id="questionContent" class="usualText"><?php echo $question_content; ?></span>
            <div class ="box_container_smaller">
                <div id="yesButton" onclick="sendRespond('<?php echo $question_id; ?>','1')"><img src="<?php echo base_url(); ?>assets/img/positive.png"/></div>
                <div id="noButton" onclick="sendRespond('<?php echo $question_id; ?>','0')"><img src="<?php echo base_url(); ?>assets/img/negative.png"/></div>
            </div>
        <?php } else { ?>
            <div class="usualText">Tidak ada pertanyaan. Silakan kembali ke awal</div>
            <br/>
            <br/>
            <br/>
            <div><a href="site"><button type="button" class="button_start" value="">Kembali ke awal</button></a></div>
        <?php } ?>
    </div>
</div>
</div>
